import pymysql
from pymysql.cursors import DictCursor

def get_db_connection():
    """获取数据库连接"""
    try:
        conn = pymysql.connect(
            host='111.198.53.163',
            port=58842,
            user='root',
            password='Zktw@2025',
            database='twrpa',
            charset='utf8mb4',
            cursorclass=DictCursor
        )
        return conn
    except Exception as e:
        print(f"数据库连接错误: {str(e)}")
        raise 